package com.pu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pu.entity.Setmeal;
import com.pu.entity.SetmealDish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author Yusc
 * @Date 2023/10/27 11:21
 * @Version
 * @Description 套餐和菜品数据访问层
 **/
@Mapper
public interface SetmealDishMapper extends BaseMapper<SetmealDish> {
    /**
     * @param ids
     * @auther: Yusc
     * @date 2023/10/27 11:24
     * @Description 根据菜品id查套餐id
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * @param setmealDishes
     * @auther: Yusc
     * @date 2023/10/28 17:52
     * @Description 批量保存套餐和菜品的关联关系
     */
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
    * @auther: Yusc
    * @param dishId
    * @date 2023/10/28 23:04
    * @Description 根据菜品id查套餐
    */
    @Select("select a.* from setmeal a left join setmeal_dish b on a.id = b.setmeal_id where b.dish_id = #{dishId}")
    List<Setmeal> getByDishId(Long dishId);
}
